/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package datos;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Ing. Monica Merlo, Ing. Agustin  Fernandez
 */
@Entity
@Table(name = "responsableObra")
@NamedQueries({@NamedQuery(name = "ResponsableObra.findAll", query = "SELECT r FROM ResponsableObra r"),
@NamedQuery(name = "ResponsableObra.findById", query = "SELECT r FROM ResponsableObra r WHERE r.id = :id"),
@NamedQuery(name = "ResponsableObra.findByNombre", query = "SELECT r FROM ResponsableObra r WHERE r.nombre = :nombre"),
@NamedQuery(name = "ResponsableObra.findByApellido", query = "SELECT r FROM ResponsableObra r WHERE r.apellido = :apellido"),
@NamedQuery(name = "ResponsableObra.findByNumeroDocumento", query = "SELECT r FROM ResponsableObra r WHERE r.numeroDocumento = :numeroDocumento")})
public class ResponsableObra implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "nombre")
    private String nombre;
    @Basic(optional = false)
    @Column(name = "apellido")
    private String apellido;
    @Column(name = "numeroDocumento")
    private Integer numeroDocumento;
    @JoinColumn(name = "idDomicilio", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Domicilio idDomicilio;
    @JoinColumn(name = "idTipoDocumento", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private TipoDocumento idTipoDocumento;
    @JoinColumn(name = "idEmpresa", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private EmpresaContratista idEmpresa;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPersona")
    private Collection<TelefonoPersona> telefonoPersonaCollection;
    @OneToMany(mappedBy = "idResponsable")
    private Collection<Obra> obraCollection;

    public ResponsableObra() {
    }

    public ResponsableObra(Integer id) {
        this.id = id;
    }

    public ResponsableObra(Integer id, String nombre, String apellido) {
        this.id = id;
        this.nombre = nombre;
        this.apellido = apellido;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getApellido() {
        return apellido;
    }

    public void setApellido(String apellido) {
        this.apellido = apellido;
    }

    public Integer getNumeroDocumento() {
        return numeroDocumento;
    }

    public void setNumeroDocumento(Integer numeroDocumento) {
        this.numeroDocumento = numeroDocumento;
    }

    public Domicilio getIdDomicilio() {
        return idDomicilio;
    }

    public void setIdDomicilio(Domicilio idDomicilio) {
        this.idDomicilio = idDomicilio;
    }

    public TipoDocumento getIdTipoDocumento() {
        return idTipoDocumento;
    }

    public void setIdTipoDocumento(TipoDocumento idTipoDocumento) {
        this.idTipoDocumento = idTipoDocumento;
    }

    public EmpresaContratista getIdEmpresa() {
        return idEmpresa;
    }

    public void setIdEmpresa(EmpresaContratista idEmpresa) {
        this.idEmpresa = idEmpresa;
    }

    public Collection<TelefonoPersona> getTelefonoPersonaCollection() {
        return telefonoPersonaCollection;
    }

    public void setTelefonoPersonaCollection(Collection<TelefonoPersona> telefonoPersonaCollection) {
        this.telefonoPersonaCollection = telefonoPersonaCollection;
    }

    public Collection<Obra> getObraCollection() {
        return obraCollection;
    }

    public void setObraCollection(Collection<Obra> obraCollection) {
        this.obraCollection = obraCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ResponsableObra)) {
            return false;
        }
        ResponsableObra other = (ResponsableObra) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "datos.ResponsableObra[id=" + id + "]";
    }

}
